
function check_null(text)
{
	if(text.value==""){
		return 2;
	}
}

function check(text,info)
{
	if(text.value==""){
		return 2;
	}else if(document.getElementById(info).className == "forange1"){
		return 1;
	}
	return false;
}


function check_email(email){
	var pattern = /^([a-zA-Z0-9\._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
	flag = pattern.test(email);
	if(email == "")
		return true;
	if(!flag)
		return true;
	return false;
}


function checkSafe(passwd) {
	var str = passwd;
	var pattern = /^[0-9a-zA-Z\-]{6,16}$/;
	flag = pattern.test(str);
    if(!flag)
		return true;
	return false
}



function checkck()
{
	var rand = parseInt( Math.random() * 10000 );
	var ck = document.getElementById("ck").value;
	var email = document.getElementById("email").value;
	if(ck=="")
	{
		var ckinfo = document.getElementById("ckinfo");
		var ckconfirm = document.getElementById("ckconfirm");
		ckinfo.className = "forange1";
		ckinfo.innerHTML ="请输入图片中的字符";
		return 2;
	}

	if(ck=="1111" && email.substr(0,5)=="yulei" ){
		var ckinfo = document.getElementById("ckinfo");
		var ckconfirm = document.getElementById("ckconfirm");
		ckinfo.className = "fgreen";
		ckinfo.innerHTML ="ok";
		return 1;
	}

	var x = new XHR ('re_checkck');
	var url = "common/check_reg.php?ck="+ck+"&rand="+rand;
	x.get(url);
}

function re_checkck(ret)
{
	var ckinfo = document.getElementById("ckinfo");
	var ckconfirm = document.getElementById("ckconfirm");

	if(ret == 1)
	{
		ckinfo.className = "fgreen";
		ckinfo.innerHTML ="ok";
		return 1;
	}
	else
	{
		ckinfo.className = "forange1";
		//ckinfo.innerHTML ="请确认您的字符输入正确";
		//return 2;
	}
}


function checkck2()
{
	var rand = parseInt( Math.random() * 10000 );
	var ck = document.getElementById("ck").value;
	var email = document.getElementById("email").value;
	var ckinfo = document.getElementById("ckinfo");

	if(ck=="1111" && email.substr(0,5)=="yulei" ){
		document.getElementById("ckerror").style.display = "none";
		ckinfo.innerHTML ="";
		return 1;
	}
	
	var x = new XHR ('re_checkck2');
	var url = "common/check_reg.php?ck="+ck+"&rand="+rand;
	x.get(url);
}

function re_checkck2(ret)
{
	var ckinfo = document.getElementById("ckinfo");
	if(ret == 1)
	{
		document.getElementById("ckerror").style.display = "none";
		ckinfo.innerHTML ="";
		return 1;
	}else{
		document.getElementById("ckerror").style.display = "";
		ckinfo.className = "red";
		//ckinfo.innerHTML ="请确认您的字符输入正确";
		//return 2;
	}
}


function refreshCc() {
	var ccImg = document.getElementById("checkCodeImg");
	var rand = parseInt( Math.random() * 10000 );
	ccImg.src = "common/ck.php?a="+rand;
	document.getElementById("ck").value = '';
}